package top.baselitch.sample.dbutils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DbHelper extends SQLiteOpenHelper {
    private static final String DB_NAME = "test.db";//数据库名称
    private static final int DB_VERSION = 1;//数据库版本号
    public static final String TABLE_NAME = "user";//表名称
    public DbHelper(Context context){
        super(context,DB_NAME,null,DB_VERSION);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "CREATE TABLE IF NOT EXISTS %s (" +
                "_id INTEGER PRIMARY KEY AUTOINCREMENT," +
                "userName VARCHAR(20)," +
                "email VARCHAR(20)," +
                "passwd VARCHAR(20))";
        db.execSQL(String.format(sql,TABLE_NAME));//创建数据库
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
